package com.Xht.www.servlet;

//后端响应管理员同意充值申请的请求

import com.Xht.www.service.UserAdmin;
import com.Xht.www.serviceImpl.UserAdminImpl;
import com.google.gson.Gson;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

@WebServlet("/ApproveRechargeServlet")
public class ApproveRechargeServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int walletId = Integer.parseInt(request.getParameter("walletId"));
        UserAdmin userAdmin = new UserAdminImpl();
        boolean success = userAdmin.approveRecharge(walletId);

        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        Map<String, Boolean> result = new HashMap<>();
        result.put("success", success);
        Gson gson = new Gson();
        out.print(gson.toJson(result));
        out.flush();
    }
}
